<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <div>我是首页</div>
    <p></p>
    <script>
      let p = document.querySelector("p");
      console.log(location.search);
      let params = location.search.substr(1);
      console.log(params);
      let arr = params.split("=");
      console.log(arr[0]);
      p.innerHTML = arr[1];
      // if (
      //   /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(
      //     navigator.userAgent
      //   )
      // ) {
      //   alert("移动");
      // } else {
      //   alert("PC");
      // }
       //定义一个函数判断是手机端还是pc端
        // function isMobile(){
        //     if(window.navigator.userAgent.match(/(phone|pad|pod|iPhone|iPod|ios|iPad|Android|Mobile|BlackBerry|IEMobile|MQQBrowser|JUC|Fennec|wOSBrowser|BrowserNG|WebOS|Symbian|Windows Phone)/i)) {
        //       return true; // 移动端
        //     }else{
        //       return false; // PC端
        //     }
        // }
        // //    判断后的操作
        // if(isMobile()){
        //     location.href="./手机端页面.html"
        //     // 判断true跳转到这个主页
        // }else{
        
        //     location.href="./首页登录.html"
        //        alert("PC")
        //     // 判断false跳转到这个主页
        // }
 console.log(navigator.userAgent);
  let os = function (){
    var ua = navigator.userAgent,
    isWindowsPhone = /(?:Windows Phone)/.test(ua),
    isSymbian = /(?:SymbianOS)/.test(ua) || isWindowsPhone,
    isAndroid = /(?:Android)/.test(ua),
    isFireFox = /(?:Firefox)/.test(ua),
    isChrome = /(?:Chrome|CriOS)/.test(ua),
    isTablet = /(?:iPad|PlayBook)/.test(ua) || (isAndroid && !/(?:Mobile)/.test(ua)) || (isFireFox && /(?:Tablet)/.test(ua)),
    isPhone = /(?:iPhone)/.test(ua) && !isTablet,
    isPc = !isPhone && !isAndroid && !isSymbian;
    return {
        isTablet: isTablet,
        isPhone: isPhone,
        isAndroid: isAndroid,
        isPc: isPc
    };
}();
if (os.isAndroid || os.isPhone) {
  console.log("手机")
} else if (os.isTablet) {
  console.log("平板")
} else if(os.isPc) {
  console.log("电脑")
}

    </script>
  </body>
</html>
